package org.tale.bootdemo.controller;

import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.alibaba.nacos.api.exception.NacosException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

/**
 * @program: boot-base
 * @author: tale-mi
 * @description:
 * @create: 2021/4/12 17:36
 **/
@Controller
@RequestMapping("config")
public class ConfigController {
    @NacosValue(value = "${useLocalCache:false}", autoRefreshed = true)
//    @Value(value = "${useLocalCache:false}")
    private boolean useLocalCache;

    @NacosValue(value = "${alert.secret:111}", autoRefreshed = true)
    private String secret;
    
    @NacosInjected
    private ConfigService configService;
    
    @RequestMapping(value = "/get", method = GET)
    @ResponseBody
    public String get() throws NacosException {
//        String result=configService.getConfig("zzt-12379-dev.yml", "zzt-12379", 5000);
//        System.out.println(result);
        System.out.println(secret);
        System.out.println(useLocalCache);
        return secret;
    }
    
    
}
